package com.example.redis.repository;

import com.example.redis.domain.UserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserRepository extends JpaRepository<UserDO, Integer> {

    UserDO findUserById(Integer id);

    @Modifying
    @Query("update tb_user set money = :money where id=:userId")
    int updateAmount(@Param("userId") Integer userId, @Param("money") Integer money);


    @Query("select id from tb_user where money>:money ")
    public List<Integer> findByMoney(@Param("money") Integer money);

}